﻿namespace Sidvall.Data
{
    public class RelationItem
    {
        #region Public Members

        public string SourceAlias { get; set; }
        public string RelatedTableName { get; set; }
        public string RelatedExpression { get; set; }
        public string RelatedAlias { get; set; }
        public RelationType RelationType { get; set; }
        #region Fields

        private RelationFieldItemCollection _Fields;
        public RelationFieldItemCollection Fields
        {
            get
            {
                if (_Fields == null)
                    _Fields = new RelationFieldItemCollection();
                return _Fields;
            }
        }

        #endregion
        #region RelatedAliasResolved

        public string RelatedAliasResolved
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(this.RelatedAlias))
                    return this.RelatedAlias;
                return this.RelatedTableName;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public RelationItem()
        {
        }

        #endregion
    }
}
